package com.chuiyan.topnews;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import com.chuiyan.topnews.Adapter.CollectAdapter;
import com.chuiyan.topnews.Adapter.CommentAdapter;
import com.chuiyan.topnews.Adapter.HistoryAdapter;
import com.chuiyan.topnews.Adapter.LikeAdapter;
import com.chuiyan.topnews.bean.TCollect;
import com.chuiyan.topnews.bean.TComment;
import com.chuiyan.topnews.bean.THistory;
import com.chuiyan.topnews.bean.TLike;

import java.util.ArrayList;

public class Info extends AppCompatActivity{
    private ListView listView;
    private ArrayList<TComment> commentData=new ArrayList<TComment>();
    private ArrayList<TCollect> collectData=new ArrayList<TCollect>();
    private ArrayList<TLike> likeData=new ArrayList<TLike>();
    private ArrayList<THistory> historyData=new ArrayList<THistory>();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.info);
        listView = (ListView) findViewById(R.id.listView);

        InitInfo();
        int value=getIntent().getIntExtra("classvalue",0);

        CollectAdapter collectadapter = new CollectAdapter(this, collectData);
        CommentAdapter commentadapter=new CommentAdapter(getApplicationContext(),commentData);
        LikeAdapter likeadapter=new LikeAdapter(getApplicationContext(),likeData);
        HistoryAdapter historyadapter=new HistoryAdapter(getApplicationContext(),historyData);
        switch (value){
            case 2:listView.setAdapter(historyadapter);break;
            case 3:listView.setAdapter(likeadapter);break;
            case 4:listView.setAdapter(collectadapter);break;
            case 5:listView.setAdapter(commentadapter);break;
        }

    }

    private void InitInfo() {
        TCollect collect1=new TCollect();
        collect1.setcNTitle("collect1");
        collectData.add(collect1);
        TCollect collect2=new TCollect();
        collect2.setcNTitle("collect2");
        collectData.add(collect2);

        TComment comment=new TComment();
        comment.setcNTitle("comment1");
        comment.setChtml("comment");
        commentData.add(comment);
        TComment comment2=new TComment();
        comment2.setcNTitle("comment2");
        comment2.setChtml("comment");
        commentData.add(comment2);

        TLike like1=new TLike();
        like1.setlNTitle("like1");
        likeData.add(like1);
        TLike like2=new TLike();
        like2.setlNTitle("like2");
        likeData.add(like2);

        THistory history1=new THistory();
        history1.sethNTitle("history1");
        historyData.add(history1);
        THistory history2=new THistory();
        history2.sethNTitle("history2");
        historyData.add(history2);
    }
}
